<?php
/*
 * Created on 2009-7-19
 *
 * Author: guobin@yizin.net
 */
global $header;
global $footer;
global $menu;

global $message;
global $roles;
global $pageNav;
global $facet;
global $keyword;

global $featureManager;
$header['title'] = '角色列表 - 用户管理';
$header['head'] = '';
$featureManager->apply("com.yizin.platform.admin.header", $header);
$menu['current'] = 'user.role';
$featureManager->apply("com.yizin.platform.admin.menu", $menu);
$featureManager->apply("com.yizin.platform.admin.footer", $footer);

?>
<?= $header['html'] ?>
<div class="ysi-container-C">
		
	<form id="delete-form" action="<?=REQUEST_BASE?>admin/user/role/delete/" method="post">
		<input type="hidden" id="serials-input" name="serials" />
	</form>
	
    <div class="ysi-container-CI">
        <div class="admin-heading">
<h2>用户批量管理</h2>
</div>
<?php if ($message) { ?><div class="ysi-message ysi-message-info"><?= $message ?></div><?php } ?>
        <div>
            <input type="button" value="创建角色" onclick="window.location.href='<?=REQUEST_BASE?>admin/user/role/new/';"/>
            <select id="action-select">
                <option value="">批量动作</option>
                <option value="delete">删除</option>
            </select>
            <input type="button" value="执行" onclick="var select=document.getElementById('action-select');var action=select.options[select.selectedIndex].value; var serialObjs=document.getElementsByName('serial'); var serials=[];for(var i=0;i<serialObjs.length;i++){if(serialObjs[i].checked)serials.push(serialObjs[i].value);}serials=serials.join(',');if(action=='delete' && serials!=''){if(confirm('确定要删除？')){document.getElementById('serials-input').value=serials; document.getElementById('delete-form').submit(); }}" />
            <?= $pageNav ?>
        </div>
				<?= ysi_vspace() ?>
        <table class="ysi-table">
            <tr>
                <th style="width:5px;">
                    <input type="checkbox" value="all" onclick="var objs=document.getElementsByName('serial'); for(var i in objs){objs[i].checked=this.checked;}"/>
                </th>
                <th>
                    ID
                </th>
                <th>
                    名称
                </th>
                <th style="width:4.5em">
                    用户数量
                </th>
                <th>
                    说明
                </th>
                <th style="width:19em">
                    控制
                </th>
            </tr>
            <?php
            foreach ($roles as $role)
            {
            ?>
            <tr>
                <td class="focused">
                    <input type="checkbox" name="serial" value="<?=$role['serial']?>" />
                </td>
                <td class="focused">
                    <?= $role['id'] ?>
                </td>
                <td>
                    <?= $role['name'] ?>
                </td>
                <td>
                    <?= $role['user_count'] ?>
                </td>
                <td>
                    <?= $role['description'] ?>
                </td>
                <td>
                    <a href="<?=REQUEST_BASE?>admin/user/role/<?=$role['serial']?>/">编辑</a>
                    <a href="<?=REQUEST_BASE?>admin/user/user/role/<?=$role['id']?>/">列出用户</a>
                    <a href="<?=REQUEST_BASE?>admin/user/role/grant/?roleSerial=<?=$role['serial']?>&from=role">设置用户</a>
                    <a href="<?=REQUEST_BASE?>admin/user/role/<?=$role['serial']?>/privilege/">编辑权限</a>
                    <a href="#" onclick="if(confirm('确定要删除？')){document.getElementById('serials-input').value='<?=$role['serial']?>'; document.getElementById('delete-form').submit(); }">删除</a>
                </td>
            </tr>
            <?php
            }
            ?>
        </table>
				
        <div>
            <input type="button" value="创建角色" onclick="window.location.href='<?=REQUEST_BASE?>admin/user/role/new/';"/>
            <select>
                <option>批量动作</option>
                <option>删除</option>
            </select>
            <input type="button" value="执行" />
            <?= $pageNav ?>
        </div>
    </div>
</div>
<div class="ysi-container-L">
    <?= $menu['html'] ?>
</div>
<?= $footer['html'] ?>
